#include "iostream"
#include "vector"
#include "string"
#include "unordered_map"

using std::vector;
using namespace std;

class Solution
{
public:
    vector<int> combine_vecs(vector<vector<int>> vecs)
    {
        int size = 0;
        for (auto &vec : vecs)
        {
            size += vec.size();
        }
        vector<int> final(size);
        vector<int> readpos(vecs.size()); //读取位置
        for (int i = 0; i < size; i++)
        { //i 对应下一个写入位置
            int min = INT32_MAX;
            int min_vec = 0; //记录从第几个数组取出
            for (int j = 0; j < vecs.size(); ++j)
            {
                //遍历数组
                if (readpos[j] < vecs[j].size())
                {
                    //还可以读取
                    auto &vec = vecs[j];
                    if (vec[readpos[j]] < min)
                    {
                        min = readpos[j];
                        min_vec = j;
                    }
                }
            }
            final[i] = min;
            readpos[min_vec]++;
        }
    }
};

int main()
{

    auto vec = Solution().combine_vecs({{3, 2, 1}, {3, 2, 1}});

    return 0;
}
